package com.fragrance.controller;

import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;

import javax.servlet.ServletInputStream;
import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.jfinal.core.Controller;

/**
 * 接受硬件信息
 * 
 * @author zhilin
 *
 */
@Deprecated
public class SimBossController extends Controller {

	private Logger logger = LoggerFactory.getLogger(SimBossController.class);

	// 访问地址：/web/api/getSimMsg (controllerKey + 方法名)
	public void getSimMsg() {
		System.out.println("收到请求："+ getPara("name"));
		logger.debug("收到请求："+ getPara("name"));
		HttpServletRequest request = getRequest();
		ServletInputStream input = null;
		BufferedInputStream bufferIn = null;
		byte[] buffer = new byte[1024];
		ByteArrayOutputStream out = null;
		try {
			int len = -1;
			input = request.getInputStream();
			out = new ByteArrayOutputStream();
			bufferIn = new BufferedInputStream(input);
			while ((len = bufferIn.read(buffer)) != -1) {
				out.write(buffer, 0, len);
			}
			buffer = out.toByteArray();
			if (buffer.length > 0) {
				String src = new String();
				logger.info("src = " + src);
				System.out.println(src);
			}
		} catch (Exception e) {
			logger.info("发生异常", e);
		}
		logger.debug("接受数据完毕");
		renderNull();
	}

}
